﻿/**
 * @author sminutoli
 */
class com.dinmax.flash.utilities.math.MathUtils {
	
	public static function isPair(n:Number):Boolean {
		var n2:Number = Math.floor(n/2);
		return (n2 == n/2);
	};
	
	public static function randomRange(min:Number, max:Number):Number {
    	var randomNum:Number = Math.floor(Math.random() * (max - min + 1)) + min;
	    return randomNum;
	};
	
	public static function getUnsortSerie(nElements:Number):Array {
		//creo la lista de indices
		var a:Array = new Array();
		for(var i:Number = 0; i < nElements; i++){
			a.push(i);
		}
		//creo el nuevo array
		var b:Array = new Array();
		while(a.length > 0){
			var nIndex = MathUtils.randomRange(0, a.length - 1);
			b.push(a.splice(nIndex, 1));
		}
		return b;
	}
		
};